//
//  CarSubBrandsCell.m
//  
//
//  Created by 微 醺 on 15/10/6.
//
//

#import "CarSubBrandsCell.h"
#import "SearchModel.h"

@implementation CarSubBrandsCell

#pragma mark - 重写初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.iconView = [[UIImageView alloc]init];
//        self.iconView.backgroundColor = [UIColor redColor];
        self.nameLabel = [[UILabel alloc]init];
//        self.nameLabel.backgroundColor = [UIColor cyanColor];
        self.priceLabel = [[UILabel alloc]init];
//        self.priceLabel.backgroundColor = [UIColor greenColor];
        self.lineView = [[UIImageView alloc]init];

        
        [self.contentView addSubview:self.iconView];
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.priceLabel];
        [self.contentView addSubview:self.lineView];
        
    }
    return self;
}
#pragma mark - 重写model类set方法
- (void) setModel:(SearchModel *)model
{
    if (_model != model) {
        _model = model;
    }
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.contentView.backgroundColor = [UIColor blackColor];
        self.nameLabel.textColor = [UIColor whiteColor];
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.nameLabel.textColor = [UIColor blackColor];
        
    }
    [self.iconView sd_setImageWithURL:[NSURL URLWithString:self.model.icon] placeholderImage:[UIImage imageNamed:@"placeHolder"]];
    self.nameLabel.text = self.model.name;
    self.priceLabel.text = self.model.price;
    
}

#pragma mark - 布局视图
- (void)layoutSubviews
{
    
    self.iconView.frame = CGRectMake(10.0/375*self.frame.size.width, 10.0/100*self.frame.size.height, 90.0/375*self.frame.size.width, 80.0/100*self.frame.size.height);
    
    
    self.nameLabel.frame = CGRectMake(140.0/375*self.frame.size.width, 20.0/100*self.frame.size.height, 200.0/375*self.frame.size.width, 40.0/100*self.frame.size.height);
    
    
    self.priceLabel.frame = CGRectMake(140.0/375*self.frame.size.width, 55.0/100*self.frame.size.height, 200.0/375*self.frame.size.width, 30.0/100*self.frame.size.height);
    self.priceLabel.textColor = [UIColor orangeColor];
    self.priceLabel.font = [UIFont systemFontOfSize:15];
    
    
    self.lineView.frame = CGRectMake(0, self.frame.size.height-1, self.frame.size.width, SAHeight * 1);
    self.lineView.backgroundColor = [UIColor colorWithRed:244.0f/255 green:244.0f/255  blue:244.0f/255  alpha:1];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
